home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 050 / tsw.arc / DEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1986-01-01  |  11KB  |  260 lines

  1. program DEMO;
  2.  
  3. var
  4.       ACTION_NO  :  byte;
  5.       ERROR,
  6.       SCREEN_NO  :  integer;
  7.       OVER_LAY   :  boolean;
  8.  
  9. procedure PAUSE;
  10.  
  11. type REGISTER = record
  12.                       ax,bx,cx,dx,bp,si,ds,es,flags: integer;
  13.                 end;
  14. var
  15.     INTRARGS     : REGISTER;
  16.  
  17. begin
  18.     with INTRARGS do
  19.     begin
  20.          ax:=$0000;
  21.          intr($16,INTRARGS);
  22.     end;
  23. end;
  24.  
  25. procedure SLOW_DOWN;
  26.  
  27. var
  28.     INT:  integer;
  29.  
  30. begin
  31.     for INT := 0 to 10000 do
  32. end;
  33.  
  34. {*****************************************************************************}
  35. {                           PROCEDURE FILLSCREEN                              }
  36. {                                                                             }
  37. { This procedure reads images from disk files created using TURBO SCREENWORKS }
  38. { and displays the images on the monitor.  Syntax for calling FILLSCREEN is:  }
  39. {                                                                             }
  40. {       fillscreen(SCREEN_FILE,SCREEN_NUMBER,ACTION,OVER_LAY,ERROR)           }
  41. {                                                                             }
  42. {            where                                                            }
  43. {                  SCREEN_NO   = an integer expression containing the number  }
  44. {                                of the screen you wish to display.           }
  45. {                  ACTION      = an integer expression that denotes the action}
  46. {                                that is to be taken.  Actions taken either   }
  47. {                                involve the actual DISPLAY memory (what you  }
  48. {                                see on your monitor) or a storage array      }
  49. {                                called V_DATA.  Legal ACTIONS are:           }
  50. {                                                                             }
  51. {                                1 = Read a new screen into both DISPLAY      }
  52. {                                    memory and V_DATA.                       }
  53. {                                2 = Read a new screen into V_DATA only.      }
  54. {                                    This does not affect the DISPLAY memory. }
  55. {                                3 = Read a new screen into DISPLAY memory    }
  56. {                                    only.  This does not affect the screen   }
  57. {                                    data contained in V_DATA.                }
  58. {                                4 = Move the screen data from V_DATA to      }
  59. {                                    DISPLAY memory.                          }
  60. {                                5 = Move the screen data from DISPLAY memory }
  61. {                                    to V_DATA.                               }
  62. {                                                                             }
  63. {                  OVER_LAY     = a logical switch that when set to FALSE     }
  64. {                                clears the previous screen data from either  }
  65. {                                DISPLAY memory or V_DATA before loading the  }
  66. {                                new data.  If set to TRUE, the new data      }
  67. {                                simply overlays the existing data.           }
  68. {                  ERROR       = an integer expression that is returned by    }
  69. {                                FILLSCREEN as an indicator of the success of }
  70. {                                the operation.  If ERROR = 0 then the oper-  }
  71. {                                was successful.  Any other return code indi- }
  72. {                                cates that an I/O error occurred.  Consult   }
  73. {                                your pascal manual for reference.            }
  74. {                                NOTE:  It is then programmers responsibilty  }
  75. {                                to insure that the parameters passed are     }
  76. {                                valid.                                       }
  77. {*****************************************************************************}
  78.  
  79. procedure FILLSCREEN(var SCRN_NO:integer;
  80.                      var ACTION:byte;
  81.                      var OVER_LAY:boolean;
  82.                      var IOERR:integer);
  83.  
  84. type
  85.     PD    = record
  86.                PB: array[1..6] of byte;
  87.                FB: integer;
  88.             end;
  89. var
  90.     BUFFER:  array[0..127] of byte;
  91.     IF1,
  92.     IF2   :  string[12];
  93.     J,
  94.     J1,
  95.     J2    :  integer;
  96.     PR    :  PD;
  97.     PF    :  file of PD;
  98.     SF    :  file;
  99.     V_BASE:  integer absolute $0000:$0463;
  100.     V_DATA:  array[0..4000] of byte;
  101.     V_MODE:  byte absolute $0000:$0465;
  102.     V_SEG :  integer;
  103. procedure V_ON;
  104. begin;
  105.      port[V_BASE+4] := V_MODE;
  106. end;
  107. procedure V_OFF;
  108. begin;
  109.      if V_SEG = $B800 then port[V_BASE+4] := V_MODE and $F7;
  110. end;
  111.  
  112. label EXIT;
  113. begin
  114.   V_SEG := $B800;
  115.   if (mem[$0040:$0010] and 48) = 48 then V_SEG := $B000;
  116.   if ACTION < 4 then
  117.   begin
  118.        {$I-}             {**** YOU MAY WISH TO REMOVE THIS LINE ****}
  119.        IF1 := 'DEMO.SDT';
  120.        IF2 := 'DEMO.SDT';
  121.        assign(PF,IF1);assign(SF,IF2);
  122.        reset(PF);IOERR := IORESULT;
  123.        if IOERR > 0 then goto EXIT;
  124.        reset(SF);IOERR := IORESULT;
  125.        if IOERR > 0 then goto EXIT;
  126.        seek(PF,SCRN_NO);IOERR := IORESULT;
  127.        if IOERR > 0 then goto EXIT;
  128.        read(PF,PR);IOERR := IORESULT;
  129.        if IOERR > 0 then goto EXIT;
  130.        {$I+}             {**** YOU MAY WISH TO REMOVE THIS LINE ****}
  131.        if not OVER_LAY then
  132.        case ACTION of
  133.             1,2: fillchar(V_DATA[0],4000,0);
  134.             1,3: begin;
  135.                       V_OFF;
  136.                       fillchar(mem[V_SEG:0],4000,0);
  137.                       V_ON;
  138.                  end;
  139.        end;
  140.        with PR do
  141.        begin
  142.             seek(SF,FB);J := 128;
  143.             for J1 := PB[1] to PB[3] do
  144.             begin
  145.                  for J2 := PB[2] to PB[4] do
  146.                  begin
  147.                       if J = 128 then
  148.                       begin
  149.                            blockread(SF,BUFFER,1);
  150.                            J := 0;
  151.                       end;
  152.                       if ACTION < 3 then move(BUFFER[J],V_DATA[((J1-1)*160)+((J2-1)*2)],2)
  153.                       else move(BUFFER[J],mem[V_SEG:((J1-1)*160)+((J2-1)*2)],2);
  154.                       J := J + 2;
  155.                  end;
  156.             end;
  157.        end;
  158.   close(PF);
  159.   close(SF);
  160.   end;
  161.   if (ACTION <> 2) and (ACTION <> 3) then
  162.   begin
  163.        V_OFF;
  164.        if ACTION <> 5 then move(V_DATA[0],mem[V_SEG:0],4000)
  165.        else move(mem[V_SEG:0],V_DATA[0],4000);
  166.        V_ON;
  167.   end;
  168. EXIT:
  169. end;
  170.  
  171.  
  172. {----------------------------------------------------------------------------}
  173. begin
  174.  
  175.      SCREEN_NO := 1;                      { The first screen in the file      }
  176.      ACTION_NO := 1;                      { Read into DISPLAY and V_DATA      }
  177.      OVER_LAY  := false;                  { Don't overlay                     }
  178.      ERROR     := 0;                      { Initialize ERROR                  }
  179.  
  180.      fillscreen(SCREEN_NO,ACTION_NO,OVER_LAY,ERROR);
  181.  
  182.      PAUSE;                               { Let the operator press any key... }
  183.  
  184.      SCREEN_NO := 2;                      { The second screen in the file     }
  185.      ACTION_NO := 3;                      { Read into DISPLAY only            }
  186.      OVER_LAY  := true;                   { Overlay the current screen        }
  187.      ERROR     := 0;                      { Initialize ERROR                  }
  188.  
  189.      fillscreen(SCREEN_NO,ACTION_NO,OVER_LAY,ERROR);
  190.  
  191.      PAUSE;                               { Let the operator press any key... }
  192.  
  193.      SCREEN_NO := 3;                      { The third screen in the file      }
  194.      ACTION_NO := 3;                      { Read into DISPLAY only            }
  195.      OVER_LAY  := true;                   { Overlay the current screen        }
  196.      ERROR     := 0;                      { Initialize ERROR                  }
  197.  
  198.      fillscreen(SCREEN_NO,ACTION_NO,OVER_LAY,ERROR);
  199.  
  200.      PAUSE;                               { Let the operator press any key... }
  201.  
  202.      SCREEN_NO := 4;                      { The fourth screen in the file     }
  203.      ACTION_NO := 3;                      { Read into DISPLAY only            }
  204.      OVER_LAY  := false;                  { Clear the display first           }
  205.      ERROR     := 0;                      { Initialize ERROR                  }
  206.  
  207.      fillscreen(SCREEN_NO,ACTION_NO,OVER_LAY,ERROR);
  208.  
  209.                                           { While the operator is looking at  }
  210.                                           { the last screen, load the next    }
  211.                                           { screen into V_DATA                }
  212.      SCREEN_NO := 5;                      { The fifth screen in the file      }
  213.      ACTION_NO := 2;                      { Read into V_DATA only             }
  214.      OVER_LAY  := true;                   { Overlay                           }
  215.      ERROR     := 0;                      { Initialize ERROR                  }
  216.  
  217.      fillscreen(SCREEN_NO,ACTION_NO,OVER_LAY,ERROR);
  218.  
  219.      PAUSE;                               { Let the operator press any key... }
  220.  
  221.      SCREEN_NO := 0;                      { Dummy assignment                  }
  222.      ACTION_NO := 4;                      { Copy from V_DATA to DISPLAY       }
  223.      OVER_LAY  := true;                   { Dummy assignment                  }
  224.      ERROR     := 0;                      { Dummy assignment                  }
  225.  
  226.      fillscreen(SCREEN_NO,ACTION_NO,OVER_LAY,ERROR);
  227.  
  228.                                           { Now move the screen (screen #5    }
  229.                                           { overlayed onto screen #1) residing}
  230.                                           { in V_DATA to DISPLAY.  Note that  }
  231.                                           { the parameters SCN_FILE, SCRN_NO, }
  232.                                           { OVERLAY and ERROR have no effect  }
  233.                                           { here.                             }
  234.  
  235.      window(17,9,61,14);                  { Set up a window.                  }
  236.      textcolor(14);textbackground(0);     { Set colors.                       }
  237.      gotoxy(1,1);                         { Locate the cursor.                }
  238.      SLOW_DOWN;SLOW_DOWN;                 { Give the operator some time...    }
  239.      SLOW_DOWN;SLOW_DOWN;
  240.      SLOW_DOWN;SLOW_DOWN;
  241.      SLOW_DOWN;SLOW_DOWN;
  242.      SLOW_DOWN;SLOW_DOWN;                 { ...and write to the window slowly.}
  243.      writeln('And finally, we return to the very first   ');SLOW_DOWN;SLOW_DOWN;
  244.      writeln('screen in the demo.  However, in this ex-  ');SLOW_DOWN;SLOW_DOWN;
  245.      writeln('ample, an additional screen was overlayed  ');SLOW_DOWN;SLOW_DOWN;
  246.      writeln('in the background and windowing features   ');SLOW_DOWN;SLOW_DOWN;
  247.      writeln('were added.');SLOW_DOWN;
  248.      PAUSE;
  249.      writeln;SLOW_DOWN;
  250.      writeln;SLOW_DOWN;
  251.      writeln;SLOW_DOWN;
  252.      writeln;SLOW_DOWN;
  253.      writeln('      TH-TH-TH-THAT',#39,'S ALL FOLKS!!!!!!!');SLOW_DOWN;
  254.      writeln;SLOW_DOWN;
  255.      writeln;SLOW_DOWN;
  256.      PAUSE;
  257.      window(1,1,80,25);                   { Reset the window coordinate.      }
  258.      gotoxy(1,1);                         { Relocate the cursor and exit.     }
  259.      clrscr;
  260. end.